﻿using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Abp.Domain.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;

namespace LeadThing.AbpZeroTemplate.SpecialPersons
{
    /// <summary>
    /// 重点特殊人群业务管理
    /// </summary>
    public class SpecialPersonManage : IDomainService
    {
        private readonly IRepository<SpecialPerson, long> _specialPersonRepository;

        /// <summary>
        /// 构造方法
        /// </summary>
        public SpecialPersonManage(IRepository<SpecialPerson, long> specialPersonRepository)
        {
            _specialPersonRepository = specialPersonRepository;
        }

        //TODO:编写领域业务代码


        /// <summary>
        /// 获取所有文化程度
        /// </summary>
        /// <returns></returns>
        public List<ComboboxItemDto> GetAllSpeCultureList()
        {
            List<ComboboxItemDto> List = new List<ComboboxItemDto>();
            Type t = typeof(SpeCulture);
            Array arrays = Enum.GetValues(t);

            for (int i = 0; i < arrays.LongLength; i++)
            {
                SpeCulture test = (SpeCulture)arrays.GetValue(i);
                FieldInfo fieldInfo = test.GetType().GetField(test.ToString());
                object[] attribArray = fieldInfo.GetCustomAttributes(false);

                ComboboxItemDto model = new ComboboxItemDto()
                {
                    Value = Convert.ToInt32(arrays.GetValue(i)).ToString(),
                    DisplayText = ((DescriptionAttribute)attribArray[0]).Description
                };
                List.Add(model);
            }

            return List;
        }

        /// <summary>
        /// 获取所有健康状况
        /// </summary>
        /// <returns></returns>
        public List<ComboboxItemDto> GetAllSpeHealthList()
        {
            List<ComboboxItemDto> List = new List<ComboboxItemDto>();
            Type t = typeof(SpeHealth);
            Array arrays = Enum.GetValues(t);

            for (int i = 0; i < arrays.LongLength; i++)
            {
                SpeHealth test = (SpeHealth)arrays.GetValue(i);
                FieldInfo fieldInfo = test.GetType().GetField(test.ToString());
                object[] attribArray = fieldInfo.GetCustomAttributes(false);

                ComboboxItemDto model = new ComboboxItemDto()
                {
                    Value = Convert.ToInt32(arrays.GetValue(i)).ToString(),
                    DisplayText = ((DescriptionAttribute)attribArray[0]).Description
                };
                List.Add(model);
            }

            return List;
        }

        /// <summary>
        /// 获取所有民族
        /// </summary>
        /// <returns></returns>
        public List<ComboboxItemDto> GetAllSpeNationList()
        {
            List<ComboboxItemDto> List = new List<ComboboxItemDto>();
            Type t = typeof(SpeNation);
            Array arrays = Enum.GetValues(t);

            for (int i = 0; i < arrays.LongLength; i++)
            {
                SpeNation test = (SpeNation)arrays.GetValue(i);
                FieldInfo fieldInfo = test.GetType().GetField(test.ToString());
                object[] attribArray = fieldInfo.GetCustomAttributes(false);

                ComboboxItemDto model = new ComboboxItemDto()
                {
                    Value = Convert.ToInt32(arrays.GetValue(i)).ToString(),
                    DisplayText = ((DescriptionAttribute)attribArray[0]).Description
                };
                List.Add(model);
            }

            return List;
        }

        /// <summary>
        /// 获取所有政治面貌
        /// </summary>
        /// <returns></returns>
        public List<ComboboxItemDto> GetAllSpePoliticsList()
        {
            List<ComboboxItemDto> List = new List<ComboboxItemDto>();
            Type t = typeof(SpePolitics);
            Array arrays = Enum.GetValues(t);

            for (int i = 0; i < arrays.LongLength; i++)
            {
                SpePolitics test = (SpePolitics)arrays.GetValue(i);
                FieldInfo fieldInfo = test.GetType().GetField(test.ToString());
                object[] attribArray = fieldInfo.GetCustomAttributes(false);

                ComboboxItemDto model = new ComboboxItemDto()
                {
                    Value = Convert.ToInt32(arrays.GetValue(i)).ToString(),
                    DisplayText = ((DescriptionAttribute)attribArray[0]).Description
                };
                List.Add(model);
            }

            return List;
        }
        /// <summary>
        ///     初始化
        /// </summary>
        private void Init()
        {

        }
    }
}
